﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Util.Interface;
using Util.Interface.System;
using Util.SystemModel;
using Util.ServiceDAO;
using MySql.Data.MySqlClient;

namespace Util.Service
{
    public class UserService : IUser
    {
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public UserModel UserLogin(string userName, string password)
        {
            string where = " and UserName=@UserName and Password=@Password and Status=1";
            MySqlParameter[] paras = new MySqlParameter[] {
                new MySqlParameter("@UserName",userName),
                new MySqlParameter("@Password",password)
            };
            return UserDAO.SelectUserByWhere(where, paras, string.Empty).FirstOrDefault();
        }
        /// <summary>
        /// 根据用户id返回用户信息
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public UserModel GetUserModel(string userId)
        {
            return UserDAO.GetUserModel(userId);
        }

    }
}
